//
//  CameraProgram.h
//  YPC-IsBang
//
//  Created by dsw on 2019/8/26.
//  Copyright © 2019 i4season. All rights reserved.
//

#import <Foundation/Foundation.h>
// 方案代理
#import "CameraProgramDelegate.h"
// 属性缓存
#import "CameraPropertiesCache.h"
#import "CameraOperationInterface.h"

@interface CameraProgram : NSObject <CameraOperationInterface>

/// 指令发送处理队列
@property (nonatomic, strong) dispatch_queue_t commandQueue;

/// 当前图片
@property (nonatomic, strong) UIImage *currentImage;

#pragma mark - init
/// 初始化 添加观察者
- (instancetype)initWithDelegate:(id<CameraProgramDelegate>)delegate;

/// APP在前台
@property (nonatomic, assign, readonly) BOOL isForground;
#pragma mark - 相机图片操作
/// 图片过滤器
//@property (nonatomic, strong) CMImageFilter *imageFilter;

#pragma mark - 事件操作 CameraOperationInterface
#pragma mark 属性插件工具操作接口
/// 设备连接状态
@property (nonatomic, assign) CMConnectStatus status;

/// 图片方向, 回调到上层时,对图片的方向的处理, 默认 原图
//@property (nonatomic, assign) UIImageOrientation imageOrientation;

/// 当前camera type
@property (nonatomic, assign) int cameraType;//1-i4,2-lexin

#pragma mark 设备操作
/// 开关陀镜像翻转
//@property (nonatomic, assign) BOOL imageMirror;

/// 开关陀螺仪
@property (nonatomic, assign) BOOL gyroscopeSwitch;

/// 忽略休眠 (zCamera)
@property (nonatomic, assign) BOOL ignoreSleepCamera;

/// 属性数据缓存 program当前对接的设备型号/选择的分辨率/固件型号等
@property (nonatomic, strong) CameraPropertiesCache *propertiesCache;


#pragma mark - 私有属性/方法 (子类 调用/重写)
/// 方案(Program)回调给上层(IFSCameraManager)的代理
@property (nonatomic, weak) id<CameraProgramDelegate> delegate;

/// IP变更,重置初始化参数
- (void)resetSDK:(NSString *)ipAddress;

/// 释放SDK
- (void)releaseSDK;

/// 进入后台休眠
- (void)sleepSDK;

/// 进入前台唤醒
- (void)wakeSDK;

/// 处理网络变更
- (void)systemNetworkChange;

#pragma mark - 后台休眠及唤醒
/// 进入后台处理
- (void)enterBackgroundProcess;

/// 进入前台处理
- (void)enterForegroundProcess;

#pragma mark - 处理图片数据
/// 处理YUV数据
/// @param data yuv数据
/// @param type 数据处理方式, eg: kCVPixelFormatType_422YpCbCr8FullRange
- (UIImage *)parseYUVData:(NSData *)data size:(CGSize)size type:(OSType)type;

/// 转换数据 子类不需要重写
/// @param image 元数据
/// @param completion 转换完成
- (void)processingData:(NSData *)data orImage:(UIImage *)image completion:(void (^)(UIImage *))completion;

/// 转换数据 子类不需要重写
/// @param imageData 元数据
/// @param completion 转换完成
//- (void)processingImageData:(NSData *)imageData completion:(void (^)(UIImage *))completion;

/// 开始处理声音数据
- (void)startProcessAudioData;

/// 停止处理声音数据
- (void)stopProcessAudioData;

/// 检查license, 同步方法,内部可能会耗时,需要子线程处理
/// @return 结果
- (BOOL)checkLicense;

/// 上线处理, 子类在上线后需要 super 调用此方法, 此方法会处理预加载设备属性等
- (void)connectedProcess;

/// 掉线处理, 子类在掉线后需要 super 调用此方法, 此方法会清理缓存,停止录制等
- (void)disconnectProcess;

/// 处理状态变化
- (void)processConnectStatus:(CMConnectStatus)status parameter:(NSMutableDictionary *)parameter;

// Mfi手动OpenSession
- (void)manuallyMfiOpenSession;

// Mfi手动CloseSession
- (void)manuallyMfiCloseSession;

@end


